#!/usr/bin/env python
# -*- coding: utf-8

from flask import Flask, request
from flask import jsonify
import aiml

app = Flask(__name__)

k = aiml.Kernel()
k.learn("cn-startup.xml")
k.respond("load aiml cn")

@app.route('/api/v1.0/AI')
def index():

	ret = {}
	
	ret['deviceclass'] = request.args['deviceclass'].upper()
	ret['ip1'] = request.args['ip1']
	ret['feedback'] = request.args['feedback']
	
	inp = str(ret['deviceclass'])+str(ret['ip1'])+str(ret['feedback'])
	ans = k.respond(inp)
	ret['ans'] = ans
	return ans

if __name__ == '__main__':
	app.run(host='0.0.0.0')


